
#ifndef XP3_H
#define XP3_H

#include <stdint.h>

typedef struct {
	int32_t compressed;
	int64_t offset;
	int64_t original_size;
	int64_t compressed_size;
} xp3_segment_t;

typedef struct {
	int32_t encrypted;
	int64_t original_size;
	int64_t compressed_size;
	int16_t name_len;
	wchar_t* name;
	int32_t segment_number;
	xp3_segment_t* segments;
	uint32_t adlr;
} xp3_entry_t;

typedef struct {
	int entry_number;
	xp3_entry_t* entries;
} xp3_entries_t;

xp3_entries_t* read_xp3_indexes(const char* xp3_path);
void free_xp3_indexes(xp3_entries_t * entries);
int decode_xp3_entry_in_buffer(const char* path, xp3_entry_t* entry, uint8_t* buffer, void (decrypter)(uint8_t* buffer, int len));

#endif

